/*
 * hello
 *
 */

#include "derivative.h" /* include peripheral declarations */
#include "mcg.h"
#include "io.h"
#include "uart.h"
#include "led.h"

int main(void)
{
	// Change clock speed to 50 MHz
	MCG_BLPE();
	
	//set clocks for port A and E
	SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK | SIM_SCGC5_PORTA_MASK;
	
	PORTE_PCR8 = PORT_PCR_MUX(0x03);
	PORTE_PCR9 = PORT_PCR_MUX(0x03);
	
	//init led
	init_led();

	// Initialize UART
	uart_init();

	printf("Hello from Will Bartolomeo and Alex Waterman! \n\r");

	for(;;) {
		char c;
	   	while(uart_getchar_present() == 0);
	   	c = uart_getchar();
	   	printf("You pressed '%c'!\n\r", c);
	   	//toggle led
	   	toggle_led();
	}

	return 0;
}
